/**
 *
 */
package com.zhengtoon.mctoon.conv.service;

import org.springframework.stereotype.Service;

import com.zhengtoon.mctoon.conv.dto.param.UploadInputParam;
import com.zhengtoon.mctoon.conv.dto.param.UploadOutputResult;
import com.zhengtoon.mctoon.conv.service.ConvAttachmentService;
import com.zhengtoon.mctoon.conv.utils.CloudAppUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 图片 impl实现
 *
 * @author 赵康峰
 * @since 2017-05-26
 * Copyright: Copyright (c) 2017
 * Company:北京政务通科技有限公司
 */
@Service
public class ConvAttachmentServiceImpl implements ConvAttachmentService {

    @Override
    public List<UploadOutputResult> uploadAttachment(List<UploadInputParam> inputParamList) {
        List<UploadOutputResult> resultList = new ArrayList<>();

        // 遍历上传
        for (UploadInputParam input : inputParamList) {

            UploadOutputResult outputResult = new UploadOutputResult();

            // 获得公有云url
            String url = CloudAppUtils.getPublicUrl(input);

            outputResult.setFileUrl(url);

            resultList.add(outputResult);
        }

        return resultList;

    }
}